﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Helpers" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers" %>
<%@ Import Namespace="WebHoiChoMuaBan.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    AdminManagement
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="col_left hoicho_marin_leftright content_right">
        <div class="content_group">
       <%--     <div class="col_left content_group hoicho_margin_topbottom">
                <div class="private_button_upload col_left">
                    <a href="photo_dangtai_private.html">
                        <img src="/../Content/Images/icon_plus_up.gif">
                        Sửa</a>
                </div>
                <div class="private_button_upload col_left hoicho_margin_leftright">
                    <a href="photo_dangtai_private.html">
                        <img src="/../Content/Images/icon_plus_up.gif">
                        Xóa</a>
                </div>
                <div class="private_button_upload col_left">
                    <a href="photo_dangtai_private.html">
                        <img src="/../Content/Images/icon_plus_up.gif">
                        Chuyển trạng thái</a>
                </div>
            </div>--%>
            <div class="col_right">
                <%=Html.ActionLink("Tạo admin mới", "Create", "AdminManagement", null, new { @class = "hoicho_bt_submit_reg" })%></div>
            <div class="col_right">
                <%=Html.ActionLink("Tạo nhóm admin", "CreateGroup", "AdminManagement", null, new { @class = "hoicho_bt_submit_reg" })%></div>
            <div class="col_right">
                <%-- <%=Html.ActionLink("Phân quyền", "RightManager", "AdminManagement", new { grpId = "getGroupID" }, new { @class = "hoicho_bt_submit_reg" })%></div>--%>
                <% using (Ajax.BeginForm("RightManager", "AdminManagement", new AjaxOptions { UpdateTargetId = "updateTargetId" }))
                   { %>
                <input type="text" name="grpId" id="grpId" class="hidden" style="display:none !important;" />
                <input type="submit" value="Phân quyền" class="hoicho_bt_submit_reg" />
                <% } %>
                </div>
                <div class="clear">
                </div>
            </div>
        <div class="private_group_friend">
            <table width="100%" border="0" id="tbDanhSachNhom">
                <tr bgcolor="#f5f7fb" class="border_bottom">
                    <td width="3%">
                        <input id="checkbox" class="input_checkbox" type="checkbox" name="checkbox" />
                    </td>
                    <td width="60%">
                        <p class="font_bold" for="checkbox5">
                            Nội dung</p>
                    </td>
                    <td width="10%" align="center">
                        <p class="font_bold">
                            Trạng thái</p>
                    </td>
                    <td width="30%">
                        &nbsp;
                    </td>
                </tr>
                <%List<WebHoiChoMuaBan.Models.Group> lstGroup = new AdminHelper().getAllGroup();
                  foreach (WebHoiChoMuaBan.Models.Group grp in lstGroup)
                  {
                      
                %>
                <tr>
                    <td>
                        <input id="checkbox2" class="input_checkbox" type="checkbox" value="<%=grp.GroupID %>"
                            name="checkbox2" onclick='clearAllRadios(this)' />
                    </td>
                    <td>
                        <span class="font_bold">
                            <%=grp.GroupName %></span><%=grp.Description %>
                    </td>
                    <td align="center">
                        <a href="#">Xuất bản</a>
                    </td>
                    <td align="right">
                        <div class="private_button_upload col_right">
                            <a href="#" onclick="deleteGroup(<%=grp.GroupID %>)">
                                <img src="/../Content/Images/icon_plus_up.gif">
                                Xóa</a>
                        </div>
                      <%--  <div class="private_button_upload col_right hoicho_margin_leftright">
                            <a href="photo_dangtai_private.html">
                                <img src="/../Content/Images/icon_plus_up.gif">
                                Sửa</a>
                        </div>--%>
                        <div class="private_button_upload col_right hoicho_margin_leftright">
                            <a href="<%=Url.Action("ViewGroup","AdminManagement",new{grpId =grp.GroupID }) %>">
                                <img src="/../Content/Images/icon_plus_up.gif">
                                Sửa</a>
                        </div>
                    </td>
                </tr>
                <%
}
                %>
            </table>
        </div>
  <%--      <div class="col_left hoicho_margin_leftright font_bold">
            <a href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">4</a> <a href="#">
                5</a> <a href="#">6</a> <a href="#">7</a> <a href="#">8</a> <a href="#">9</a>
            <a href="#">10</a> <a href="#">11</a> <a href="#">12</a> ... <a href="#">Trang sau</a></div>--%>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadHolder" runat="server">
    <script type="text/javascript">

        function clearAllRadios(obj) {
            var input = document.getElementsByTagName("input");
            for (var i = 0; i < input.length; i++) {
                if (input[i].checked) input[i].checked = false;
            }
            obj.checked = true;
            var ff = document.getElementById("grpId");
            ff.value = obj.value;
        }

        function RightManager() {

            var spid = 0;
            for (var i = 0; i < input.length; i++) {
                if (input[i].checked == true) {
                    spid = input[i].value;
                    break;
                }
            }
            $.ajax({
                type: "POST",
                url: "/AdminManagement/RightManager",
                data: "grpId=" + spid,
                success: function (result) {
                },
                error: function (req, status, error) {
                    alert("Sorry! We could not receive your feedback at this time.");
                }
            });
        }
    </script>
    
</asp:Content>
